package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.qf.mapper.DtsRoleMapper;
import com.qf.pojo.DtsRole;
import com.qf.service.DtsRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

@Service
public class DtsRoleServiceImpl implements DtsRoleService {
    @Autowired
    DtsRoleMapper dtsRoleMapper;
    @Override
    public Set<String> findRoleById(Integer[] roleIds) {
//        LambdaQueryWrapper<DtsRole> qw = new LambdaQueryWrapper<>();
//        qw.in(DtsRole::getId,roleIds);
//        List<DtsRole> dtsRoles = dtsRoleMapper.selectList(qw);
//        Set<String > roles = dtsRoles.stream().map(Role -> {
//            return Role.getName();
//        }).collect(Collectors.toSet());
//        return roles;

        LambdaQueryWrapper<DtsRole> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.in(DtsRole::getId,roleIds);
        List<DtsRole> dtsRoles = dtsRoleMapper.selectList(queryWrapper);
        Set<String> roleStrs = dtsRoles.stream().map(Role-> {
            return Role.getName();
        }).collect(Collectors.toSet());
        return roleStrs;
    }
}
